<% %>
<div class=page_head>
<h2><%='Post new file(s)'.t%></h2>
</div>
<link href="/stylesheets/swfupload.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/javascripts/swfupload.js"></script>
<script type="text/javascript" src="/javascripts/handlers.js"></script>
<script type="text/javascript" src="/javascripts/swfupload.queue.js"></script>
<script type="text/javascript" src="/javascripts/fileprogress.js"></script>
<script >
var swfu;
window.onload = function() {
    var settings = {
        // Flash Settings
        flash_url : "/flash/swfupload.swf",	// Relative to this file
         // Backend Settings
	upload_url: "/files/save?uni_id=<%=session.session_id%>&pid=<%=params[:project_id]%>",	// Relative to the SWF file
	post_params: {"sessionid" : "<%=session.to_s%>"},
	// File Upload Settings
        file_size_limit : <%=@cur_user.company.plan.max_size.to_i / 1024%>,	// 100MB
        file_types : "*.*",
        file_types_description : "All Files",
        file_upload_limit : 10,
        file_queue_limit : 0,
        begin_upload_on_queue : true,
	custom_settings : {
	   progressTarget : "fsUploadProgress",
	   cancelButtonId : "btnCancel"
	   },

        
	/*
	// Event Handler Settings
        file_queued_handler : uploadStart,
        file_progress_handler : uploadProgress,
        file_cancelled_handler : uploadCancel,
        file_complete_handler : uploadComplete,
        queue_complete_handler : uploadQueueComplete,
        error_handler : uploadError,
	*/
       // The event handler functions are defined in handlers.js
				file_queued_handler : fileQueued,
				file_queue_error_handler : fileQueueError,
				file_dialog_complete_handler : fileDialogComplete,
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgress,
				upload_error_handler : uploadError,
				upload_success_handler : uploadSuccess,
				upload_complete_handler : uploadComplete,
				queue_complete_handler : queueComplete,	// Queue plugin event

  // Button settings
				button_image_url: "/images/file_button_upload.png",	// Relative to the Flash file
				button_width: "195",
				button_height: "29",
				button_placeholder_id: "spanButtonPlaceHolder",
				button_text: '<span class=\"theFont\"><%="Browse file ... (Max".t + " " + number_to_human_size(@cur_user.company.plan.max_size.to_i) + ")"%></span>',
				button_text_style: ".theFont { font-size:14px;font-familay:arial;font-weight:bold }",
				button_text_left_padding:10,
				button_text_top_padding: 2,


        
	// UI Settings
        //ui_container_id : "flashUI1",
        //degraded_container_id : "degradedUI1",

        // Debug Settings
        debug: false 
};
      swfu = new SWFUpload(settings);
     //upload1.addSetting("progress_target", "fsUploadProgress1");	// Add an additional setting that will later be used by the handler.

}
</script>
<% form_remote_for(:files, :url => project_files_path(params[:project_id])) do |f| %>
<div class="FormBlock">
<div class=extra>
<div id=files>
<%=render :partial=>'files/uploaded_files',:locals=>{:uni_id=>session.session_id}%>
</div>
<div id="Attachments" class="showhide" style="border:2px #fff solid;background:#fff">
<div class="content">
<table>
<tr valign="top">
<td>
  <input id=uni_id type=hidden value='<%=session.session_id%>'>
  <input id=project_id type=hidden value='<%=params[:project_id]%>'>
<!--
  <div id="flashUI1" style="display: none;">
    <div>
       <input type="button" value="<%="Browse file ... (Max".t + " " + number_to_human_size(@cur_user.company.plan.max_size.to_i) + ")"%>" onclick="upload1.browse()" style="font-weight:bold" />
       <input id="btnCancel1" type="button" value="<%="Cancel Uploads".t%>" onclick="upload1.cancelQueue();" disabled="disabled"/><br />
    </div>

   <fieldset class="flash" id="fsUploadProgress1"> <legend><%="Attached Files".t%></legend></fieldset>
   </div>
-->

		<div class="fieldset flash" id="fsUploadProgress"> </div>
  		<div id="divStatus">0 Files Uploaded</div>
		<div>
                    <span id="spanButtonPlaceHolder"></span>
                    <input id="btnCancel" type="button" value="Cancel All Uploads" onclick="swfu.cancelQueue();" disabled="disabled" />
                </div>



   <!--
   <div id="degradedUI1"> 
     <div> <input type="submit" value="Submit Files" /> </div>
   </div>
   -->
  </td>
  </tr>
</table>
</div>
</div>
</div>
<!-- attach files-->
</div>

<div class=extra>
<h2><%="Nottify people of this message by Email".t%>:</h2>
<%=check_box_tag "all",'',false,{:onclick=>"togglePeople('all_user')",:id=>'all_user'}%>
  <strong><%="All of the %s" / @project.name%></strong><br/>
<%@project.users.each do |u|%>
  <%=check_box_tag "notify_id[]",u.id,false,:class=>'all_user',:onclick=>"$('all_user').checked = false"%><%=u.name%>
<%end%>
</div>
<div class="submit">
    <div id="please_wait" style="display: none">
      <%=image_tag "progress_bar.gif"%> 
    </div>
    <div id="buttons">
    <%= submit_tag "Post these files".t,:onclick=>"Element.hide('buttons');Element.show('please_wait')"%> <%="or".t%> <%=link_to "Cancel".t,"javascript:history.back()",:class=>'admin'%>
    </div>
  </div>
<% end %>


